package com.gss.util.common;

import java.util.List;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.gss.domain.stock.ItemDetailsDTO;
import com.gss.persistance.stock.ItemDAO;

@Component
public class BootupLoader 
{
	@Autowired
	ItemDAO itemDAO;
	
	@PostConstruct
	public void initMethod(){
		loadAllItem();
	}
	private void loadAllItem()
	{
		List<ItemDetailsDTO> detailsDTOs = itemDAO.loadAllItem();
		for(ItemDetailsDTO itemDetailsDTO:detailsDTOs)
		{
			ApplicationConstant.ITEM_NAME_ID_MAP.put(itemDetailsDTO.getItemName(), itemDetailsDTO.getItemId());
			ApplicationConstant.ITEM_ID_ITEM_MAP.put(itemDetailsDTO.getItemName(), itemDetailsDTO);
			ApplicationConstant.ITEM_STOCK_MAP.put(itemDetailsDTO.getItemName(), itemDetailsDTO.getItemStock());
		}
	}
}
